<#include "../common/header.htm">
<div class="content-wrapper">
	<section class="content-header">
		<ol class="breadcrumb">
			<li><a href="${ctx}/">首页</a></li>
			<li class="active"><a href="#">待接收</a></li>
		</ol>
	</section>
	<section class="content">
		<div class="work-list-switch">
			<a href="${ctx}/feedbacklist/noreceive" <#if menu?? && menu=="noreceive">class="current"</#if> >待接收</a>
			<a href="${ctx}/feedbacklist/nodeal" <#if menu?? && menu=="nodeal">class="current"</#if> >待处理</a>
			<a href="${ctx}/feedbacklist/feedBack/create" <#if menu?? && menu=="create">class="current"</#if> >我创建的</a>
			<a href="${ctx}/feedbacklist/feedBack/trustees" <#if menu?? && menu=="trustees">class="current"</#if> >我经办的</a>
			<a href="${ctx}/feedbacklist/feedBack/participants" <#if menu?? && menu=="participants">class="current"</#if> >我参与的</a>
		</div>
		<div class="box">
		 <form action="${ctx}/feedbacklist/noreceive" id="listForm">
			<div class="box-header">
				<div class="row">
					<div class="col-sm-11">
						<div class="col-sm-2" style="display: -webkit-box;">
							<label class="input_text">类型：</label> 
							<select class="form-control" style="width: 200px;" name="feedBackParentType" >
								<option value="">请选择</option>
								<#list parentTypeMap as key, value>
									<#if params?? && params.feedBackParentType?? && (params.feedBackParentType == key)>
										<option value="${key}" selected="selected">${value}</option>
										<#else>
										<option value="${key}" >${value}</option>
									</#if>
								</#list>
							</select>
							<select class="form-control" style="width: 200px;margin-left:20px;" name="feedbackType" >
								<option value="">请选择</option>
							</select>
						</div>
						<div class="col-sm-2" style="display: -webkit-box;margin-left: 270px;">
							<label>关键字：</label> 
							<input name="keyword" type="text" class="form-control" placeholder="请输入编号/标题" value="${params.keyword!}"/>
						</div>
						<div class="col-sm-1" style="padding-left: 50px;">
							 <input type="button" class="btn btn-default btn-search" onclick="feedback.query();" value="查询" />
						</div>
					</div>
				</div>
			</div>
			<div class="box-body">
				<table class="table table-hover table-bordered table-striped table-hide">
					<thead>
						<tr>
							<th width="4%">序号</th>
							<th width="11%">编号</th>
							<th width="15%">标题</th>
							<th width="11%">类型</th>
							<th width="8%">申请人</th>
							<th width="11%">申请时间</th>
							<th width="11%">当前经办人</th>
							<th width="11%">最新处理时间</th>
							<th width="10%">进度</th>
							<th width="8%">操作</th>
						</tr>
					</thead>
					<tbody>
						<#list page.content as w>
						<tr>
							<td>${page.size*page.number+w_index+1}</td>
							<td>${w.problemFeedBackNo!}</td>
							<td title="${w.title!}">${w.title!}</td>
							<#if w.feedbackType?? && feedBackMergeTypeMap["${w.feedbackType}"]?? >
								<td>${feedBackMergeTypeMap["${w.feedbackType}"]!}</td>
							<#else>
								<td></td>
							</#if>
							<td>${w.createrName!}</td>
							<td>${w.createrTime?string("yyyy-MM-dd HH:mm:ss")}</td>
							<td><@mymacro.firstNotEmpty w.currentDealUserName! w.currentDealGroupName!></@mymacro.firstNotEmpty></td>
							<td>${w.lastDealTime?string("yyyy-MM-dd HH:mm:ss")}</td>
							<#if w.currentDealTag?? && tagMap["${w.currentDealTag}"]?? >
								<td>${tagMap["${w.currentDealTag}"]!}</td>
							<#else>
								<td></td>
							</#if>
							<td>
								<a onclick="feedback.toreceive('${w.id}', '${w.lastRecordId}', '${w.title}')" href="javascript:void(0)">接收</a>&nbsp;&nbsp;
								<a href="${ctx}/feedBack/detail?problemFeedBackId=${w.id}&problemFeedbackRecordId=${w.lastRecordId}&title=${title}&url=${url}">详情</a>
							</td>
						</tr>
						</#list>
					</tbody>
				</table>
				<#include "../common/page.htm">
			</div>
		  </form>
		</div>
	</section>
</div>
<#include "../common/footer.htm">
<script type="text/javascript">
	var is_submit=false;
	/* 反馈子类型 */
	var subType = {
		<#list subTypeMap as k, v>
			"${k}": "${v}",
		</#list>
	};
	
	/* 反馈父类型切换 */
	$("select[name='feedBackParentType']").change(function() {
		$("select[name='feedbackType']").html('<option value="">请选择</option>');
		var parentType = $(this).val();
		if (parentType) {
			for (key in subType) {
				if (key.substring(0,key.indexOf('_')) == parentType) {
					$("select[name='feedbackType']").append('<option value="' + key + '">' + subType[key] + '</option>');
				}
			}
		}		
	});
	
	/* 反馈类型汇总 */
	var feedBackMergeType = {
		<#list feedBackMergeTypeMap as k, v>
			"${k}": "${v}",
		</#list>
	};
	/* 设置查询返回类型选中 */
	var feedBackType = "${params.feedbackType!''}";
	var parentType = "${params.feedBackParentType!}";
	if (parentType) {
		for (key in feedBackMergeType) {
			if (key.startsWith(parentType)) {
				if (key == feedBackType) {
					$("select[name='feedbackType']").append('<option value="' + key + '" selected>' + subType[key] + '</option>');
				} else {
					$("select[name='feedbackType']").append('<option value="' + key + '">' + subType[key] + '</option>');
				}
			}
		}
	}
	var feedback = {
		query : function() {
			$(":input[name='pageNumber']").val(0);
			$("form").submit();
		},
		toreceive : function(id,lastRecordId,wtitle) {
			// console.log("wtitle=" + encodeURIComponent(wtitle));
			var title ="反馈接收";
			if(is_submit){
				return;
			}
			is_submit = true;
			var j = 0;
			base.getView({
				url:"${ctx}/feedBack/toreceive?feedBackId="+id+"&feedBackRecordId="+lastRecordId+"&wtitle="+encodeURIComponent(wtitle),
				success:function(result){
					bootbox.dialog({
						title:title,
						message:result,
						size:"large",
						closeButton : false,
						buttons:{
							cancel:{
								label:"取消",
								className:"btn btn-secondary",
								callback:function(){
									is_submit=false;
								}
							},
							sure:{
								label:"确定",
								className:"btn btn-primary",
								callback:function(){
									if (j != 0) {
										is_submit=false;
										return ;
									}
									j++;
									base.validAndAjaxSubmit($("#receive"), $("#listForm"), function () {
										j = 0;
									});
									return false;
								}
							}
						}
					})
				}
			})
		}
	}
</script>